package cn.com.lyj6851.user.controller;

import java.util.UUID;

import org.springframework.http.ResponseEntity;
import org.springframework.http.ResponseEntity.BodyBuilder;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.com.lyj6851.common.util.BeanValidator;
import cn.com.lyj6851.user.entity.UserRole;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 〈功能简述〉<br>
 * 〈用户角色〉
 *
 */
@RestController
@RequestMapping("userrole")
@Api(tags = "用户角色Controller")
public class UserRoleController {

	@PostMapping("userrole")
    @ApiOperation(value = "新增")
    public BodyBuilder add(UserRole userRole) {
		BeanValidator.check(userRole);
        userRole.setId(UUID.randomUUID().toString());
        userRole.insert();
        return ResponseEntity.ok();
    }

    @DeleteMapping("userrole")
    @ApiOperation(value = "删除")
    public BodyBuilder delete(UserRole userRole) {
        userRole.deleteById();
        return ResponseEntity.ok();
    }

    @PutMapping("userrole")
    @ApiOperation(value = "修改")
    public BodyBuilder update(UserRole userRole){
    	BeanValidator.check(userRole);
        userRole.updateById();
        return ResponseEntity.ok();
    }
}
